from django.shortcuts import render
from django.db import connection


def cursor_index(request):
    # 获取游标对象
    cursor = connection.cursor()
    # 拿到游标对象后执行sql语句
    # cursor.execute(f"""INSERT into book VALUES(NULL, '三国演义', '罗贯中');""")
    # 获取所有数据
    cursor.execute(f"""SELECT id, name, author FROM book;""")
    rows = cursor.fetchall()
    for row in rows:
        print(row)
    return render(request, 'cursor/index.html')

